<?php

namespace admin\models;

use Yii;
use yii\helpers\ArrayHelper;

/**
 * This is the model class for table "mm_relation".
 *
 * @property integer $mr_id
 * @property integer $mu_id
 * @property integer $mr_type
 * @property string $mr_name
 */
class Relation extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'mm_relation';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['mu_id', 'mr_type'], 'integer'],
            [['mr_name'], 'string', 'max' => 20],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'mr_id' => 'Mr ID',
            'mu_id' => '用户id',
            'mr_type' => '关系类型，1唯一，2多个',
            'mr_name' => '关系名',
        ];
    }

    public static function getRelations(){
        $relationArr = self::find()->asArray()->all();
        $relations = ArrayHelper::map($relationArr,'mr_id','mr_name');
        return $relations;
    }
}
